package com.onLineCar.dispatch;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.data.geo.Point;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;

@SpringBootApplication
@Slf4j
@EnableFeignClients
@EnableDiscoveryClient
@SuppressWarnings("all")
@EnableRabbit
@MapperScan("com.onLineCar.dispatch.mapper")
@EnableScheduling
public class DispatchEngineApplication {
    public static void main(String[] args) {
        SpringApplication.run(DispatchEngineApplication.class);
    }

    @Resource
    private RedisTemplate redisTemplate;

    @PostConstruct
    public void init() {
        log.info("-------------DispatchEngineApplication init------------------");
        HashMap<String, Point> pointStringHashMap = new HashMap<>();
        pointStringHashMap.put("driverId-123456-vehicleId-1", new Point(121.695493, 30.870626));
        pointStringHashMap.put("dirverId-123457-vehicleId-2", new Point(121.689062, 30.860365));
        pointStringHashMap.put("dirverId-123458-vehicleId-3", new Point(121.700315, 30.87336));
//        pointStringHashMap.put("dirverId-123459-vehicleId-261", new Point(121.702354, 30.871463));
        Long addedNum = redisTemplate.opsForGeo().add("city-312000", pointStringHashMap);
        log.info("-------------插入成功：{}------------------", addedNum);
    }
}
